home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / os2 / wr06002.zip / WR06002.CMD next >
OS/2 REXX Batch file  |  1993-01-27  |  16KB  |  417 lines

  1. /****************************************************************************
  2.  
  3.         Module Name             = WR06002.CMD
  4.  
  5.         Descriptive Name        = SelectPak 2 (Database Precompilers)
  6.                                   install tool
  7.  
  8.         Copyright               = 04G1049  (C) Copyright IBM Corp. 1988, 1991.
  9.                                   All rights reserved.
  10.                                   US Government Users Restricted Rights -
  11.                                   Use, duplication or disclosure restricted by
  12.                                   GSA ADP Schedule Contract with IBM Corp.
  13.  
  14.                                   Licensed Materials - Property of IBM
  15.  
  16.         Function                = Installation tool for SelectPak 002
  17.  
  18.         Operating System        = OS/2 Extended Services
  19.  
  20. ****************************************************************************/
  21.  
  22. signal on halt          /* call HALT: routine on CTRL-BREAK */
  23. "echo off"
  24.  
  25. /*************************************************/
  26. /* Read in command line arguements if they exist */
  27. /*************************************************/
  28. parse upper arg Base_Drive Update_Drive Backed .
  29.  
  30.  
  31. /***********************************************************/
  32. /* Verify that the Database SelectPak message file exists  */
  33. /***********************************************************/
  34. MSG_FILE = stream('WR06DBM.MSG' , 'c' , 'query exists')
  35. if MSG_FILE = "" then
  36.         do
  37.         say " ERROR: could not find message file WR06DBM.MSG "
  38.         signal End
  39.         end
  40.  
  41. /***************************************************/
  42. /* Read the message file into an array of messages */
  43. /***************************************************/
  44. do while lines(MSG_FILE) \= 0    /* While not at EOF  */
  45.  
  46.         text_of_message = MSG_Parse(linein(MSG_FILE))
  47.         MSG.message_number = text_of_message
  48.  
  49. end                              /* End of While loop */
  50.  
  51.  
  52. /**************************************/
  53. /*  Close the message file            */
  54. /**************************************/
  55. RC = stream('WR06DBM.MSG' , 'c' , 'close')
  56.  
  57. start:
  58. "cls"
  59.  
  60. /****************************************/
  61. /*  One possible input parameter is '?' */
  62. /*  Display the help panel in this case */
  63. /****************************************/
  64. if Base_Drive = "?" then signal syntax
  65.  
  66. /*************************/
  67. /*  Introductory panel   */
  68. /*************************/
  69. say
  70. say
  71. say centre(MSG.40,50)
  72. say centre(Create_MSG(MSG.01,'002'),50)
  73. say centre(MSG.02,50)
  74. say
  75. say
  76.  
  77. /***************************************************/
  78. /* The Base Drive letter is the Drive letter that  */
  79. /* contains the Base Operating System.             */
  80. /***************************************************/
  81. get_Base_Drive:
  82. if Base_Drive \= "" then signal got_Base_Drive
  83. call charout ,"  "MSG.03" "
  84. parse upper linein Base_Drive
  85. if Base_Drive = "" then
  86.         do
  87.         say "  "MSG.04
  88.         signal get_Base_Drive
  89.         end
  90.  
  91. got_Base_Drive:
  92. /*************************************************/
  93. /* Verify that the \OS2\INSTALL directory exists */
  94. /* on the drive specified by the user            */
  95. /*************************************************/
  96. Base_Drive = substr(Base_Drive, 1, 1)
  97. "dir "Base_Drive":\OS2\INSTALL                                   >  NUL  2>>&1"
  98. if RC \= 0 then
  99.         do
  100.         say
  101.         say "  "Create_MSG2(MSG.05,Base_Drive,'\OS2\INSTALL')
  102.         say "  "Create_MSG(MSG.06,'\OS2\INSTALL')
  103.         say "  "MSG.07
  104.         parse linein ignore
  105.         Base_Drive = ""
  106.         signal get_Base_Drive
  107.         end
  108.  
  109. /***************************************************/
  110. /* The log varible will contain the full path name */
  111. /* of the output log.  The output log will contain */
  112. /* any error messages from this installation       */
  113. /***************************************************/
  114. LOG = ""Base_Drive":\OS2\INSTALL\WR06002.LOG"
  115. say
  116. say "  "Create_MSG(MSG.08,LOG)
  117. say
  118. say
  119.  
  120. /******************************************************/
  121. /* The Update Drive letter is the letter of the Drive */
  122. /* containing the Database system directory that      */
  123. /* you wish to upgrade.                               */
  124. /******************************************************/
  125. get_Update_Drive:
  126. if Update_Drive \= "" then signal got_Update_Drive
  127. call charout ,"  "MSG.09" "
  128. parse upper linein Update_Drive
  129. if Update_Drive = "" then
  130.         do
  131.         say "  "MSG.04
  132.         signal get_Update_Drive
  133.         end
  134.  
  135. got_Update_Drive:
  136. /*************************************************/
  137. /* Verify that the \SQLLIB directory exists      */
  138. /* on the drive specified by the user            */
  139. /*************************************************/
  140. Update_Drive = substr(Update_Drive, 1, 1)
  141. "dir "Update_Drive":\SQLLIB                                      >  NUL  2>>&1"
  142. if RC \= 0 then
  143.         do
  144.         say
  145.         say "  "Create_MSG2(MSG.05,Update_Drive,'\SQLLIB')
  146.         say "  "Create_MSG(MSG.06,'\SQLLIB')
  147.         say "  "MSG.07
  148.         parse linein ignore
  149.         Update_Drive = ""
  150.         signal get_Update_Drive
  151.         end
  152.  
  153. /***********************************************************/
  154. /* Display to the user, the directory that will be updated */
  155. /***********************************************************/
  156. say
  157. say "  "Create_MSG2(MSG.12,Update_Drive,'SQLLIB')
  158. say
  159.  
  160. Backup:
  161. /***********************************************************/
  162. /* Ask the user if they would like the old files to be     */
  163. /* backed up to the current directory.                     */
  164. /***********************************************************/
  165. say
  166. say "  "Create_MSG(MSG.13,'0.26')
  167. call charout , "  "Create_MSG(MSG.14,Backed)
  168.  
  169. if Backed \= "" then signal got_Backup
  170. parse upper linein Backed
  171. got_Backup:
  172. if Backed  = "0" then signal verify
  173. if Backed \= "1" then              /* Only 0 and 1 are acceptable inputs */
  174.         do
  175.         say
  176.         say "  "MSG.15
  177.         Backed = ""
  178.         signal Backup
  179.         end
  180.  
  181. verify:
  182. /*************************************************/
  183. /* Ask for verification of the input parameters. */
  184. /* This is done even if the user is using the    */
  185. /* command line interface.                       */
  186. /*************************************************/
  187. say
  188. say
  189. call charout ,"  "MSG.16" "
  190. parse upper linein Verified
  191. if Verified  = "0" then        /* If the user answers NO to verification */
  192.         do                     /* then reset all of the input parameters */
  193.         Base_Drive = ""        /* and go back to the start.              */
  194.         Update_Drive = ""
  195.         Backed = ""
  196.         Verified = ""
  197.         signal start
  198.         end
  199.  
  200. if Verified \= "1" then        /* Only 0 and 1 are acceptable inputs */
  201.         do
  202.         say
  203.         say "  "MSG.15
  204.         Verified = ""
  205.         signal verify
  206.         end
  207. say
  208.  
  209. /*****************************************************************************/
  210. /*                                                                           */
  211. /* Set up the following variables:                                           */
  212. /* SYSLEVEL: The fully qualified path name of the SYSLEVEL file for database */
  213. /* SQL_PATH: The fully qualified path name of the SQLLIB        directory    */
  214. /* DLL_PATH: The fully qualified path name of the SQLLIB\DLL    directory    */
  215. /* REQ_PATH: The fully qualified path name of the SQLLIB\REQDLL directory    */
  216. /*                                                                           */
  217. /*****************************************************************************/
  218.  
  219. SYSLEVEL = Update_Drive":\SQLLIB\SYSLEVEL.SQL"
  220. SQL_PATH = Update_Drive":\SQLLIB"
  221. DLL_PATH = Update_Drive":\SQLLIB\DLL"
  222. REQ_PATH = Update_Drive":\SQLLIB\REQDLL"
  223.  
  224.  
  225. /*******************************************************************/
  226. /* Check to see that the customer has WR06000 or WR06010 installed */
  227. /* by reading the syslevel file.                                   */
  228. /*******************************************************************/
  229. firstline = linein(SYSLEVEL)
  230.  
  231. /*****************************************************/
  232. /* Close the syslevel file so that it can be updated */
  233. /*****************************************************/
  234. RC = stream(SYSLEVEL,'c','close')
  235.  
  236. /************************************************************/
  237. /* CSD_LEVEL will contain the current level of service and  */
  238. /* PAK_TYPE will tell us weather this installation was from */
  239. /* a server package or requester package.                   */
  240. /************************************************************/
  241. csd_level = substr(firstline,45,7)
  242. pak_type  = substr(firstline,101,8)
  243.  
  244. /**************************************************************/
  245. /* Only allow this installation if the users current CSD      */
  246. /* level is WR06000 ( ES 1.0 ) or WR06010 ( ES 1.0 plus this  */
  247. /* first round of SelectPaks )                                */
  248. /**************************************************************/
  249. if csd_level \= 'WR06010' & csd_level \= 'WR06000' then
  250. do
  251.         say
  252.         say "  "MSG.17
  253.         say "  "MSG.18
  254.         say "  "MSG.19
  255.         say
  256.         signal End
  257. end
  258.  
  259. /***********************************************************/
  260. /*  If the initial installation was from a server package, */
  261. /*  then install SYSLEVEL.SQS as SYSLEVEL.SQL.  Otherwise  */
  262. /*  install SYSLEVEL.SQC as SYSLEVEL.SQL.                  */
  263. /***********************************************************/
  264. if pak_type = 'with Ser' then SYSLVL_FILE = SYSLEVEL.SQS
  265.                          else SYSLVL_FILE = SYSLEVEL.SQC
  266.  
  267. "echo.                                                           >> "LOG" 2>>&1"
  268. "echo " centre(MSG.40,50)                                     "  >> "LOG" 2>>&1"
  269. "echo " centre(Create_MSG(MSG.01,'002'),50)                   "  >> "LOG" 2>>&1"
  270. "echo.                                                           >> "LOG" 2>>&1"
  271. "echo.                                                           >> "LOG" 2>>&1"
  272. "echo.                                                           >> "LOG" 2>>&1"
  273.  
  274. /***********************************************************************/
  275. /* If the user had chosen to backup the old version of the files,      */
  276. /* then copy the files that will be changing from the SQLLIB directory */
  277. /* to the current directory.                                           */
  278. /***********************************************************************/
  279. if Backed  = "0" then signal skip_Backup
  280. "echo "MSG.20 SQL_PATH"\SQLABIND.BND                             >>"LOG" 2>>&1"
  281. "copy "SQL_PATH"\SQLABIND.BND                                    >>"LOG" 2>>&1"
  282. "echo "MSG.20 SQL_PATH"\SYSLEVEL.SQL                             >>"LOG" 2>>&1"
  283. "copy "SQL_PATH"\SYSLEVEL.SQL SYSLVOLD.SQL                       >>"LOG" 2>>&1"
  284.  
  285. "echo "MSG.20 DLL_PATH"\SQLA.DLL                                 >>"LOG" 2>>&1"
  286. "copy "DLL_PATH"\SQLA.DLL                                        >>"LOG" 2>>&1"
  287. "echo "MSG.20 DLL_PATH"\SQLAB.DLL                                >>"LOG" 2>>&1"
  288. "copy "DLL_PATH"\SQLAB.DLL                                       >>"LOG" 2>>&1"
  289. "echo "MSG.20 DLL_PATH"\SQLAC.DLL                                >>"LOG" 2>>&1"
  290. "copy "DLL_PATH"\SQLAC.DLL                                       >>"LOG" 2>>&1"
  291. "echo "MSG.20 DLL_PATH"\SQLAK.DLL                                >>"LOG" 2>>&1"
  292. "copy "DLL_PATH"\SQLAK.DLL                                       >>"LOG" 2>>&1"
  293. "echo "MSG.20 DLL_PATH"\SQLAR.DLL                                >>"LOG" 2>>&1"
  294. "copy "DLL_PATH"\SQLAR.DLL                                       >>"LOG" 2>>&1"
  295.  
  296. skip_Backup:
  297.  
  298.  
  299. /***************************************************************************/
  300. /* Unzip the SQLLIB files   -n means only unzip newer files                */
  301. /*                          -d means create directories stored in ZIP file */
  302. /***************************************************************************/
  303. "PKUNZIP2 -n -d WR06002.SPK "SQL_PATH"\                          >>"LOG" 2>>&1"
  304. if RC = 0 then signal Zip_Done1
  305.  
  306. if RC = 11 then  /* Make a note in the log if no files were unziped */
  307.         do
  308.         say
  309.         say "  "Create_MSG(MSG.21,SQL_PATH)
  310.         signal Zip_Done1
  311.         end
  312.  
  313. /****************************************************************************/
  314. /* If there were any errors then tell the user that there were problems.    */
  315. /****************************************************************************/
  316. say "  "MSG.22
  317. say "  "Create_MSG(MSG.23,LOG)
  318. say "  "
  319. say "  "MSG.07
  320. parse linein ignore
  321.  
  322.  
  323. Zip_Done1:
  324. /**********************************************************************/
  325. /* Update the SYSLEVEL file to indicate a SelectPak has been applied  */
  326. /**********************************************************************/
  327. "echo "MSG.24"                                                   >>"LOG" 2>>&1"
  328. "attrib -r "SQL_PATH"\SYSLEVEL.SQL                               >  NUL  2>>&1"
  329. "copy "SQL_PATH"\"SYSLVL_FILE     SQL_PATH"\SYSLEVEL.SQL         >>"LOG" 2>>&1"
  330. "del "SQL_PATH"\SYSLEVEL.SQS                                     >>"LOG" 2>>&1"
  331. "del "SQL_PATH"\SYSLEVEL.SQC                                     >>"LOG" 2>>&1"
  332. "attrib +r "SQL_PATH"\SYSLEVEL.SQL                               >  NUL  2>>&1"
  333.  
  334.  
  335. Done:
  336.  
  337. /**************************************************************/
  338. /* The installation is now complete, inform the user and exit */
  339. /**************************************************************/
  340. say
  341. say centre(Create_MSG(MSG.25,'WR06002'),50)
  342. say
  343. signal End
  344.  
  345. /***********************************************************/
  346. /* This routine will be called if the user uses CTRL-BREAK */
  347. /***********************************************************/
  348. HALT:
  349. say
  350. say
  351. say MSG.26
  352. say MSG.27
  353. say
  354. signal End
  355.  
  356. /* Help panel */
  357. syntax:
  358. say
  359. say "  "Create_MSG(MSG.28,'WR06002')
  360. say
  361. say "  "MSG.29
  362. say "      "MSG.30
  363. say "         "Create_MSG(MSG.31,'\OS2\INSTALL')
  364. say "      "MSG.32
  365. say "         "Create_MSG(MSG.31,'\SQLLIB')
  366. say "      "MSG.34
  367. say "         "Create_MSG(MSG.35,'0.26')
  368. say "      "MSG.36
  369. say "         "MSG.37
  370. say
  371. say
  372. say "  "Create_MSG(MSG.38,'WR06002')
  373. say "      WR06002 C C 1                                                 "
  374. say "  "MSG.39
  375. say
  376. say
  377. signal End
  378.  
  379.  
  380. /*****************************************************************/
  381. /* This routine will take a message and a variable and place the */
  382. /* variable in the proper position in the string.                */
  383. /*****************************************************************/
  384. Create_MSG:
  385. parse arg MESSAGE,VARIABLE
  386. PART1 = SUBSTR(MESSAGE,1,POS('%1',MESSAGE)-1)
  387. PART2 = SUBSTR(MESSAGE,POS('%1',MESSAGE)+2)
  388. RETURN PART1 || VARIABLE || PART2
  389.  
  390.  
  391. /*********************************************************************/
  392. /* This routine will take a message and two variables and place the  */
  393. /* variables in their proper positions in the string.                */
  394. /*********************************************************************/
  395. Create_MSG2:
  396. parse arg MESSAGE,VARIABLE1,VARIABLE2
  397. POS1 = POS('%1',MESSAGE)
  398. POS2 = POS('%2',MESSAGE)
  399. PART1 = SUBSTR(MESSAGE,1,POS1-1)
  400. PART2 = SUBSTR(MESSAGE,POS1+2,POS2-POS1-2)
  401. PART3 = SUBSTR(MESSAGE,POS2+2)
  402. RETURN PART1 || VARIABLE1 || PART2 || VARIABLE2 || PART3
  403.  
  404.  
  405. /*******************************************************************/
  406. /* This routine will take a message line from the message file     */
  407. /* and parse it into a message number and a text string            */
  408. /*******************************************************************/
  409. MSG_Parse:
  410. parse arg MESSAGE
  411. TEXT = SUBSTR(MESSAGE,POS(' ',MESSAGE)+1)
  412. message_number = SUBSTR(MESSAGE,1,POS(' ',MESSAGE)-1)
  413. RETURN TEXT
  414.  
  415.  
  416. End:
  417.